package com.examples.ry.graphics;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class DrawFigures {

	public static void main(String[] args) {
		final Display display = new Display();
		final Color allOnes = new Color(display, 255, 255, 255);
		final Shell shell = new Shell(display);
		shell.addListener(SWT.Paint, new Listener() {
			public void handleEvent(Event event) {
				GC gc = event.gc;
				gc.drawRectangle(10, 10, 200, 100);
				gc.fillRectangle(10, 10, 200, 100);
				gc.drawRectangle(new Rectangle(20, 20, 180, 80));
				//gc.fillRectangle(new Rectangle(20, 20, 180, 80));
				gc.drawRoundRectangle(30, 30, 160, 60, 30, 20);
				//gc.fillRoundRectangle(30, 30, 160, 60, 30, 20);
				gc.drawFocus(40, 40, 140, 40);
				gc.drawOval(50, 50, 120, 20);
				//gc.fillOval(50, 50, 120, 20);
				gc.setLineWidth(30);
				gc.setForeground(allOnes);
				gc.setXORMode(true);
				gc.drawArc(10, 80, 200, 180, 45, 90);
				//gc.fillArc(10, 80, 200, 180, 45, 90);
				gc.setXORMode(false);
			}
		});
		shell.setText("Figures");
		shell.setSize(250, 150);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		allOnes.dispose();
		display.dispose();
	}

}
